package com.home.oss.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Description:
 * Created by 王大宸 on 2020-10-15 23:15
 * Created with IntelliJ IDEA.
 */
@Configuration
public class OssWebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private FileConfig fileConfig;


    /***
     * 功能说明：静态资源文件配置 文件访问地址配置
     *
     * @author 王大宸
     * @date 2020/10/15 23:16
     * @param registry registry
     * @return void
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/upload/**").addResourceLocations("file:" + fileConfig.getUploadPath());
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + fileConfig.getUploadPath());
    }

}
